/*
 *  FXLog.h
 *
 *  Copyright 2015 https://github.com/dqjl111 All rights reserved.
 *
 *  This program is use for fuxi project
 *
 *  Created  by: Zhipeng Lin on 2016-01-30
 *  Modified by: Zhipeng Lin on 2016-01-30
 *  ************************************************************************************ */
#ifndef FXLOG_H
#define FXLOG_H
#include "base/FXStdafx.h"

#define FXLOG_SEV(level) BOOST_LOG_SEV(fx::log::slg, level)
#define FXLOG BOOST_LOG(fx::log::lg)

namespace logging = boost::log;
namespace attrs = boost::log::attributes;
namespace src = boost::log::sources;
namespace sinks = boost::log::sinks;
namespace expr = boost::log::expressions;
namespace keywords = boost::log::keywords;


namespace fx{
enum SeverityLevel
{
    Info,
    Notice,
    Debug,
    Warning,
    Error,
    Fatal
};

namespace log{
// The formatting logic for the severity level
template< typename CharT, typename TraitsT >
inline std::basic_ostream< CharT, TraitsT >& operator<< (
    std::basic_ostream< CharT, TraitsT >& strm, SeverityLevel lvl)
{
    static const char* const str[] =
    {
        "Info",
        "Notice",
        "Debug",
        "Warning",
        "Error",
        "Fatal"
    };
    if (static_cast< std::size_t >(lvl) < (sizeof(str) / sizeof(*str)))
        strm << str[lvl];
    else
        strm << static_cast< int >(lvl);
    return strm;
}

BOOST_LOG_ATTRIBUTE_KEYWORD(log_severity, "Severity", SeverityLevel)
BOOST_LOG_ATTRIBUTE_KEYWORD(log_timestamp, "TimeStamp", boost::posix_time::ptime)
BOOST_LOG_ATTRIBUTE_KEYWORD(log_uptime, "Uptime", attrs::timer::value_type)
BOOST_LOG_ATTRIBUTE_KEYWORD(log_scope, "Scope", attrs::named_scope::value_type)


void InitLog(std::string logPath = "logs");

extern src::logger lg;
extern src::severity_logger<SeverityLevel > slg;
}
}


#endif // FXLOG_H

